set(
	BASE_HDRS
	process.h
	thread.h
)
list(APPEND HDRS ${BASE_HDRS})

set(
	IO_HDRS
	io/BasicIosRestorer.h
	io/Hex.h
)
list(APPEND HDRS ${IO_HDRS})

if(NOT CMAKE_VERSION VERSION_LESS 3.19)
	add_library(util INTERFACE ${HDRS})
else()
	add_library(util INTERFACE)
	add_custom_target(util_sources SOURCES ${HDRS})
endif()

if(NOT CMAKE_VERSION VERSION_LESS 3.8)
	target_compile_features(util INTERFACE cxx_std_11)
endif()

target_include_directories(
	util
	INTERFACE
	$<BUILD_INTERFACE:${rl_BINARY_DIR}/src>
	$<BUILD_INTERFACE:${rl_SOURCE_DIR}/src>
	$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/rl-${PROJECT_VERSION}>
)

if(NOT CMAKE_VERSION VERSION_LESS 3.19)
	set_target_properties(
		util
		PROPERTIES
		VERSION ${PROJECT_VERSION}
	)
endif()

install(FILES ${BASE_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rl-${PROJECT_VERSION}/rl/util COMPONENT development)
install(FILES ${IO_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rl-${PROJECT_VERSION}/rl/util/io COMPONENT development)

install(
	TARGETS util
	EXPORT rl
	ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP
	RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)
